Skip to content

Sign sub-hour UTC offsets - #1872

Merged
SimonCropp merged 1 commit into
mainfrom
fix-negative-subhour-offset
Aug 17, 2026
Merged

Sign sub-hour UTC offsets#1872
SimonCropp merged 1 commit into
mainfrom
fix-negative-subhour-offset

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

Supersedes #1868, which GitHub closed automatically when its base branch (#1854) was deleted on merge. Same change, rebased onto main.

GetDateOffset took the sign from the hour component. For an offset of less than an hour that component is zero, so TimeSpan.FromMinutes(-30) rendered as 0-30 while its positive twin rendered +0-30 — the two are indistinguishable by sign, and a negative offset silently reads as positive.

The sign now comes from the offset as a whole and the components are rendered unsigned. Every other case renders exactly as before: -1-30, -5, +1-30, +5, +0.

Only reachable with a constructed offset, since no real timezone sits in that range.

Built on top of #1854, so it keeps that PR's FormattableString.Invariant style and its theory test untouched. One line of its comment changed: the sign is now written as a literal rather than taken from a negative number, so the culture pinning covers the digits rather than the sign.

The rebase conflicted with #1856 (SubMillisecondTicks, merged since), which appends tests at the same point in DateFormatterTests. Purely additive — both kept.

DateFormatterTests.SubHourOffsets covers both signs and asserts the two no longer render the same. Verified with a local run of the full appveyor.yml build script in Release on the merged result: build clean, all 17 test projects pass.

@SimonCropp SimonCropp added this to the 32.0.0 milestone Aug 17, 2026
GetDateOffset took the sign from the hour component, which is zero for an offset
of less than an hour, so TimeSpan.FromMinutes(-30) rendered as 0-30 while its
positive twin rendered as +0-30. The sign now comes from the offset itself and
the components are rendered unsigned.

Only reachable with a constructed offset: no real timezone sits in that range.
@SimonCropp
SimonCropp force-pushed the fix-negative-subhour-offset branch from 4f6d25c to f45f2a6 Compare August 17, 2026 13:41
@SimonCropp
SimonCropp merged commit 175b49d into main Aug 17, 2026
3 checks passed
@SimonCropp
SimonCropp deleted the fix-negative-subhour-offset branch August 17, 2026 21:18
@SimonCropp
SimonCropp restored the fix-negative-subhour-offset branch August 17, 2026 21:25
This was referenced Aug 26, 2026
This was referenced Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant